/**
 * Created by Forcs on 16/4/20.
 */

var _initLogConfig = function (loggerTags, logRoot, level, def) {
  if (!loggerTags) {
    if (def) {
      def.logPath = logRoot;
    }
    return def;
  }

  var config = {
    loggerTags: loggerTags,
    logPath: logRoot,
    replaceConsole: true,
    levels: {},
    appenders: [
      {
        type: 'console',
        category: 'console'
      }
    ]
  };

  loggerTags.forEach(function (item) {
    config.appenders.push({
      type: 'dateFile',
      filename: logRoot + '/' + item,
      maxLogSize: 1024 * 1024,
      pattern: "_yyyy-MM-dd.log",
      category: item,
      alwaysIncludePattern: true
    });
    config.levels[item] = level
  });

  return config;
};

module.exports = _initLogConfig(['app'], '/tmp/corgi/logs', 'info', {});
